package com.fjwt.gz.service.activity.fans;

import com.fjwt.gz.db.dto.OldFansInfoDTO;
import com.fjwt.gz.db.entity.SysExportTaskEntity;
import com.fjwt.gz.service.activity.AbstractExportReport;
import com.fjwt.gz.service.impl.OldFansInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class OldFansInfoExportReport extends AbstractExportReport<OldFansInfoDTO> {
    @Autowired
    private OldFansInfoService oldFansInfoService;

    private static final Map<String, String> HEADER_ALIAS_MAP = new HashMap<>();
    static {
        HEADER_ALIAS_MAP.put("userNo", "客户编号");
        HEADER_ALIAS_MAP.put("realName", "姓名");
        HEADER_ALIAS_MAP.put("phone", "手机号");
        HEADER_ALIAS_MAP.put("openId", "迁移前OPID");
        HEADER_ALIAS_MAP.put("score", "福分值");
        HEADER_ALIAS_MAP.put("agentNo", "历史网点机构号");
        HEADER_ALIAS_MAP.put("agentName", "历史网点机构名称");
        HEADER_ALIAS_MAP.put("cstmNo", "信息局唯一标识");
        HEADER_ALIAS_MAP.put("authTime", "实名时间");
        HEADER_ALIAS_MAP.put("isAuth", "实名状态");
        HEADER_ALIAS_MAP.put("fansId", "客户ID");
        HEADER_ALIAS_MAP.put("state", "迁移状态");
        HEADER_ALIAS_MAP.put("newOpenId", "实际迁移后OPID");
        HEADER_ALIAS_MAP.put("syncTime", "迁移时间");
        HEADER_ALIAS_MAP.put("newAgentNo", "客户归属");
        HEADER_ALIAS_MAP.put("syncWeek", "是否周迁移");
        HEADER_ALIAS_MAP.put("syncMonth", "是否月迁移");
        HEADER_ALIAS_MAP.put("syncYear", "是否年迁移");
    }

    /**
     * 存量会员导出
     * @param sysExportTaskEntity
     * @return
     */
    @Override
    public String exportActivityExcel(SysExportTaskEntity sysExportTaskEntity) {
        OldFansInfoDTO dto = getRequestParam(sysExportTaskEntity.getRequestParam(),OldFansInfoDTO.class);
        //存量会员信息
        List<OldFansInfoDTO> list = oldFansInfoService.selectOldFansInfoByDTOList(dto);
        return createExcelAndUploadOssUrl(list, HEADER_ALIAS_MAP, sysExportTaskEntity);
    }
}
